package cn.skyquant.quant4j.service.boot.model.authority;

import cn.skyquant.quant4j.api.account.AccountDTO;
import cn.skyquant.quant4j.api.authority.UserDTO;
import org.springframework.stereotype.Component;

@Component
public class AppContext {

    private ThreadLocal<UserDTO> userLocal = new ThreadLocal<>();
    private ThreadLocal<AccountDTO> accountLocal = new ThreadLocal<>();

    public UserDTO get() {
        return userLocal.get();
    }
    public AccountDTO getAccount() {
        return accountLocal.get();
    }
    public void remove() {
        userLocal.remove();
    }

    public void set(UserDTO userDTO){
        userLocal.set(userDTO);
    }
    public void set(AccountDTO accountDTO){
        accountLocal.set(accountDTO);
    }
}
